package com.ra.landlord;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.ra.system.Version;

/**
 * 房屋附加费
 * 
 * @author Jerry.Feng Date: 2014-07-31
 */
@Entity
@Table(name = "ra_feeaddition")
public class FeeAddition implements Version, LandlordOwner {

	public static final Integer STATUS_DELETED = 0;			//已删除，暂时没用
	public static final Integer STATUS_CONFIRMED = 1;		//已确认，没有生成收租单前的都是已确认
	public static final Integer STATUS_NEED_CONFIRM = 2;	//待确认，生成收租单后产生的费用，需要再次生成收租单。

	private Integer id;
	
	private String name;
	
	//当前刻度
	private Meter meter1;
	
	//上一次刻度
	private Meter meter2;
	
	// 关联的费用总表单
	private Fee fee;
	
	// 收费依据 
	private FeeRuleCfg feeRuleCfg;
	
	// 时间段的实收费用, 单项 （比方水费用收， 管理费应收）
	private BigDecimal priceActual;
	
	// 时间段的应收实收
	private BigDecimal priceRecv;
	
	// 计算滞纳金
	private Boolean overdueFine;
	
	// 公摊费用总额（transient）
	private BigDecimal shareAmount;
	
	private LandlordOwnerUser landlordUser;
	
	private Integer version;
	
	private Integer status;
	
	@Id
	@GeneratedValue
	@Column(name = "FeeAdditionId")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "MeterIdOne")
	public Meter getMeter1() {
		return meter1;
	}

	public void setMeter1(Meter meter1) {
		this.meter1 = meter1;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "MeterIdTwo")
	public Meter getMeter2() {
		return meter2;
	}

	public void setMeter2(Meter meter2) {
		this.meter2 = meter2;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "FeeId")
	public Fee getFee() {
		return fee;
	}

	public void setFee(Fee fee) {
		this.fee = fee;
	}

	@OneToOne(targetEntity=FeeRuleCfg.class, fetch=FetchType.LAZY)
	@JoinColumn(name = "FeeItemId")
	public FeeRuleCfg getFeeRuleCfg() {
		return feeRuleCfg;
	}

	public void setFeeRuleCfg(FeeRuleCfg feeRuleCfg) {
		this.feeRuleCfg = feeRuleCfg;
	}

	@Column(name = "price_actual")
	public BigDecimal getPriceActual() {
		return priceActual;
	}

	public void setPriceActual(BigDecimal priceActual) {
		this.priceActual = priceActual;
	}

	@Column(name = "price_recv")
	public BigDecimal getPriceRecv() {
		return priceRecv;
	}

	public void setPriceRecv(BigDecimal priceRecv) {
		this.priceRecv = priceRecv;
	}
	
	@Column(name = "IsOverduefine")
	public Boolean getOverdueFine() {
		return overdueFine;
	}

	public void setOverdueFine(Boolean overdueFine) {
		this.overdueFine = overdueFine;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "createuserid")
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser = landlordUser;
	}
	
	@Transient
	public BigDecimal getShareAmount() {
		return shareAmount;
	}

	public void setShareAmount(BigDecimal shareAmount) {
		this.shareAmount = shareAmount;
	}

	@Column(name = "version_id")
	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "data_status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
